# opt.re <- se.re/sd.re
# opt.pool <- se.pool/sd.pool
opt.fe <- sd.fe/se.fe
opt.re <- sd.re/se.re
opt.pool <- sd.pool/se.pool
plot(truecor, opt.fe, pch=19, type="l", col = "#80b1d3", lwd = 3, ylim=c(0, 4), xlim=c(0, 1),
xlab=expression(rho), ylab="Overconfidence",
main=paste(unitloop, "units, ", Nperloop, "observations per unit"))
lines(truecor, opt.re, pch=19, col = "#fb8072", lwd = 3, lty=2)
lines(truecor, opt.pool, pch=19, col = "#bebada", lwd = 3, lty=3)
index <- index + 1
}
}
dev.off()
pdf("CL_Optimism_Standard.pdf", width=9, height=8)
par(mfrow=c(length(units), length(Nperunit)), mar=c(4, 4, 2, 0.5), las=1)
index <- 1
for (unitloop in units) {
for (Nperloop in Nperunit) {
sd.fe <- colSds(coeflist.fe[[index]])
sd.re <- colSds(coeflist.re[[index]])
sd.pool <- colSds(coeflist.pool[[index]])
se.fe <- colMeans(selist.fe[[index]])
se.re <- colMeans(selist.re[[index]])
se.pool <- colMeans(selist.pool[[index]])
# opt.fe <- se.fe/sd.fe
# opt.re <- se.re/sd.re
# opt.pool <- se.pool/sd.pool
opt.fe <- sd.fe/se.fe
opt.re <- sd.re/se.re
opt.pool <- sd.pool/se.pool
plot(truecor, opt.fe, pch=19, type="l", col = "#80b1d3", lwd = 3, ylim=c(0, 4), xlim=c(0, 1),
xlab=expression(rho), ylab="Overconfidence",
main=paste(unitloop, "units, ", Nperloop, "observations per unit"))
lines(truecor, opt.re, pch=19, col = "#fb8072", lwd = 3, lty=2)
lines(truecor, opt.pool, pch=19, col = "#bebada", lwd = 3, lty=3)
index <- index + 1
}
}
dev.off()
View(coefmat.fe)
View(coeflist.fe)
View(coeflist.fe)
# normality
## rho = 0, units = 10, observations per unit = 5
coeflist.fe[[1]][1, ]
# normality
## rho = 0, units = 10, observations per unit = 5
coeflist.fe[[1]][, 1]
# normality
## rho = 0, units = 10, observations per unit = 5
length(coeflist.fe[[1]][, 1])
# normality
## rho = 0, units = 10, observations per unit = 5
plot(density(coeflist.fe[[1]][, 1]))
shapiro.test(coeflist.fe[[1]][, 1])
plot(density(coeflist.re[[1]][, 1]))
shapiro.test(coeflist.re[[1]][, 1]) # not normal
## rho = 0, units = 10, observations per unit = 5
plot(density(coeflist.fe[[1]][, 1]))
shapiro.test(coeflist.re[[1]][, 1]) # not normal
## rho = 0.1, units = 10, observations per unit = 5
plot(density(coeflist.fe[[1]][, 2]))
shapiro.test(coeflist.fe[[1]][, 2]) # not normal
plot(density(coeflist.pool[[1]][, 1]))
shapiro.test(coeflist.pool[[1]][, 1]) # not normal at 90%
## rho = 0.1, units = 10, observations per unit = 5
plot(density(coeflist.fe[[1]][, 2]))
shapiro.test(coeflist.fe[[1]][, 2]) # not normal
plot(density(coeflist.re[[1]][, 2]))
shapiro.test(coeflist.re[[1]][, 2]) # not normal at 90%
shapiro.test(coeflist.re[[1]][, 2]) # normal
plot(density(coeflist.pool[[1]][, 2]))
shapiro.test(coeflist.pool[[1]][, 2]) # normal
## rho = 0.2, units = 10, observations per unit = 5
plot(density(coeflist.fe[[1]][, 3]))
shapiro.test(coeflist.fe[[1]][, 3]) # normal
plot(density(coeflist.re[[1]][, 3]))
shapiro.test(coeflist.re[[1]][, 3]) # normal
plot(density(coeflist.pool[[1]][, 3]))
shapiro.test(coeflist.pool[[1]][, 3]) # normal
## rho = 0.3, units = 10, observations per unit = 5
plot(density(coeflist.fe[[1]][, 4]))
shapiro.test(coeflist.fe[[1]][, 4]) # normal
plot(density(coeflist.re[[1]][, 4]))
shapiro.test(coeflist.re[[1]][, 4]) # normal
plot(density(coeflist.pool[[1]][, 4]))
shapiro.test(coeflist.pool[[1]][, 4]) # normal
## rho = 0.4, units = 10, observations per unit = 5
plot(density(coeflist.fe[[1]][, 5]))
shapiro.test(coeflist.fe[[1]][, 5]) # normal
plot(density(coeflist.re[[1]][, 5]))
shapiro.test(coeflist.re[[1]][, 5]) # normal
plot(density(coeflist.pool[[1]][, 5]))
shapiro.test(coeflist.pool[[1]][, 5]) # normal
## rho = 0.5, units = 10, observations per unit = 5
plot(density(coeflist.fe[[1]][, 6]))
shapiro.test(coeflist.fe[[1]][, 6]) # normal
plot(density(coeflist.re[[1]][, 6]))
shapiro.test(coeflist.re[[1]][, 6]) # normal
plot(density(coeflist.pool[[1]][, 6]))
shapiro.test(coeflist.pool[[1]][, 6]) # normal
## rho = 0.6, units = 10, observations per unit = 5
plot(density(coeflist.fe[[1]][, 7]))
shapiro.test(coeflist.fe[[1]][, 7]) # normal
plot(density(coeflist.re[[1]][, 7]))
shapiro.test(coeflist.re[[1]][, 7]) # normal
plot(density(coeflist.pool[[1]][, 7]))
shapiro.test(coeflist.pool[[1]][, 7]) # normal
## rho = 0.7, units = 10, observations per unit = 5
plot(density(coeflist.fe[[1]][, 8]))
shapiro.test(coeflist.fe[[1]][, 8]) # normal
plot(density(coeflist.re[[1]][, 8]))
shapiro.test(coeflist.re[[1]][, 8]) # normal
plot(density(coeflist.pool[[1]][, 8]))
plot(density(coeflist.pool[[1]][, 8]))
shapiro.test(coeflist.pool[[1]][, 8]) # normal
names(shapiro.test(coeflist.pool[[1]][, 8]))
shapiro.test(coeflist.pool[[1]][, 8])$
shapiro.test(coeflist.pool[[1]][, 8])$p.value
# normality
normal.pool <- matrix(data = NA, nrow = 81, ncol = 4)
# normality
normal.pool <- matrix(data = NA, nrow = 81, ncol = 4)
index <- 1
for (unitloop in units) {
for (Nperloop in Nperunit) {
for (i in length(truecorr)) {
normal.pool[index, 1] <- unitloop
index <- i + 1
}
}
}
for (unitloop in units) {
for (Nperloop in Nperunit) {
for (i in length(truecor)) {
normal.pool[index, 1] <- unitloop
index <- i + 1
}
}
}
normal.pool
# normality
normal.pool <- matrix(data = NA, nrow = 81, ncol = 4)
index <- 1
for (unitloop in units) {
for (Nperloop in Nperunit) {
for (i in length(truecor)) {
normal.pool[index, 1] <- unitloop
index <- index + 1
}
}
}
normal.pool
# normality
normal.pool <- matrix(data = NA, nrow = 81, ncol = 4)
index <- 1
for (unitloop in units) {
for (Nperloop in Nperunit) {
for (i in length(truecor)) {
normal.pool[index, 1] <- unitloop
index <- index + 1
index
}
}
}
# normality
normal.pool <- matrix(data = NA, nrow = 81, ncol = 4)
index <- 1
for (unitloop in units) {
for (Nperloop in Nperunit) {
for (i in length(truecor)) {
normal.pool[index, 1] <- unitloop
index <- index + 1
print(index)
}
}
}
# normality
normal.pool <- matrix(data = NA, nrow = 81, ncol = 4)
index <- 1
for (unitloop in units) {
for (Nperloop in Nperunit) {
for (i in length(truecor)) {
normal.pool[index, 1] <- unitloop
print(index)
}
}
}
length(truecor)
Nperunit
index <- 1
for (unitloop in units) {
for (Nperloop in Nperunit) {
for (i in 1:length(truecor)) {
normal.pool[index, 1] <- unitloop
print(index)
}
}
}
# normality
normal.pool <- matrix(data = NA, nrow = 81, ncol = 4)
index <- 1
for (unitloop in units) {
for (Nperloop in Nperunit) {
for (i in 1:length(truecor)) {
normal.pool[index, 1] <- unitloop
index <- index + 1
}
}
}
normal.pool
# normality
normal.pool <- matrix(data = NA, nrow = 81, ncol = 4)
index <- 1
for (unitloop in units) {
for (Nperloop in Nperunit) {
for (i in 1:length(truecor)) {
normal.pool[index, 1] <- unitloop
normal.pool[index, 2] <- Nperunit
normal.pool[index, 3] <- truecor[i]
index <- index + 1
}
}
}
Nperunit
unitloop
normal.pool <- matrix(data = NA, nrow = 81, ncol = 4)
index <- 1
for (unitloop in units) {
for (Nperloop in Nperunit) {
for (i in 1:length(truecor)) {
normal.pool[index, 1] <- unitloop
normal.pool[index, 2] <- Nperloop
normal.pool[index, 3] <- truecor[i]
index <- index + 1
}
}
}
normal.pool
# normality
normal.pool <- matrix(data = NA, nrow = 99, ncol = 4)
index <- 1
for (unitloop in units) {
for (Nperloop in Nperunit) {
for (i in 1:length(truecor)) {
normal.pool[index, 1] <- unitloop
normal.pool[index, 2] <- Nperloop
normal.pool[index, 3] <- truecor[i]
normal.pool[index, 3] <- truecor[i]
index <- index + 1
}
}
}
normal.pool
normal.pool <- matrix(data = NA, nrow = 99, ncol = 4)
index <- 1
for (unitloop in units) {
j <- 1
for (Nperloop in Nperunit) {
for (i in 1:length(truecor)) {
normal.pool[index, 1] <- unitloop
normal.pool[index, 2] <- Nperloop
normal.pool[index, 3] <- truecor[i]
normal.pool[index, 4] <- shapiro.test(coeflist.pool[[j]][ , i])$p.value
index <- index + 1
}
j <- j + 1
}
}
normal.pool
normal.pool <- matrix(data = NA, nrow = 99, ncol = 4)
index <- 1
for (unitloop in units) {
j <- 1
for (Nperloop in Nperunit) {
for (i in 1:length(truecor)) {
normal.pool[index, 1] <- unitloop
normal.pool[index, 2] <- Nperloop
normal.pool[index, 3] <- truecor[i]
normal.pool[index, 4] <- shapiro.test(coeflist.pool[[j]][ , i])$p.value
index <- index + 1
print(j)
}
j <- j + 1
}
}
View(coeflist.fe)
normal.pool <- matrix(data = NA, nrow = 99, ncol = 4)
index <- 1
j <- 1
for (unitloop in units) {
for (Nperloop in Nperunit) {
for (i in 1:length(truecor)) {
normal.pool[index, 1] <- unitloop
normal.pool[index, 2] <- Nperloop
normal.pool[index, 3] <- truecor[i]
normal.pool[index, 4] <- shapiro.test(coeflist.pool[[j]][ , i])$p.value
index <- index + 1
print(j)
}
j <- j + 1
}
}
# normality
normal.pool <- matrix(data = NA, nrow = 99, ncol = 6)
normal.fe <- matrix(data = NA, nrow = 99, ncol = 6)
normal.re <- matrix(data = NA, nrow = 99, ncol = 6)
index <- 1
j <- 1
for (unitloop in units) {
for (Nperloop in Nperunit) {
for (i in 1:length(truecor)) {
# pooled
normal.pool[index, 1] <- unitloop
normal.pool[index, 2] <- Nperloop
normal.pool[index, 3] <- truecor[i]
normal.pool[index, 4] <- shapiro.test(coeflist.pool[[j]][ , i])$p.value
normal.pool[index, 5] <- ifelse(shapiro.test(coeflist.pool[[j]][ , i])$p.value > 0.1, "normal", "not normal")
normal.pool[index, 6] <- ifelse(shapiro.test(coeflist.pool[[j]][ , i])$p.value >= 0.05 &
shapiro.test(coeflist.pool[[j]][ , i])$p.value <= 0.1, "normal", "not normal")
# fe
normal.fe[index, 1] <- unitloop
normal.fe[index, 2] <- Nperloop
normal.fe[index, 3] <- truecor[i]
normal.fe[index, 4] <- shapiro.test(normal.fe[[j]][ , i])$p.value
normal.fe[index, 5] <- ifelse(shapiro.test(normal.fe[[j]][ , i])$p.value > 0.1, "normal", "not normal")
normal.fe[index, 6] <- ifelse(shapiro.test(normal.fe[[j]][ , i])$p.value >= 0.05 &
shapiro.test(normal.fe[[j]][ , i])$p.value <= 0.1, "normal", "not normal")
# re
normal.re[index, 1] <- unitloop
normal.re[index, 2] <- Nperloop
normal.re[index, 3] <- truecor[i]
normal.re[index, 4] <- shapiro.test(normal.re[[j]][ , i])$p.value
normal.re[index, 5] <- ifelse(shapiro.test(normal.re[[j]][ , i])$p.value > 0.1, "normal", "not normal")
normal.re[index, 6] <- ifelse(shapiro.test(normal.re[[j]][ , i])$p.value >= 0.05 &
shapiro.test(normal.re[[j]][ , i])$p.value <= 0.1, "normal", "not normal")
index <- index + 1
print(j)
}
j <- j + 1
}
}
normal.fe[index, 5] <- ifelse(shapiro.test(normal.fe[[j]][ , i])$p.value > 0.1, "normal", "not normal")
normal.fe[index, 2] <- Nperloop
normal.fe[index, 3] <- truecor[i]
View(normal.fe)
shapiro.test(normal.fe[[j]][ , i])$p.value > 0.1
shapiro.test(normal.fe[[j]][ , i])$p.value
shapiro.test(normal.fe[[j]][ , i])$p.value
View(normal.pool)
# normality
normal.pool <- matrix(data = NA, nrow = 99, ncol = 6)
normal.fe <- matrix(data = NA, nrow = 99, ncol = 6)
normal.re <- matrix(data = NA, nrow = 99, ncol = 6)
index <- 1
j <- 1
for (unitloop in units) {
for (Nperloop in Nperunit) {
for (i in 1:length(truecor)) {
# pooled
normal.pool[index, 1] <- unitloop
normal.pool[index, 2] <- Nperloop
normal.pool[index, 3] <- truecor[i]
normal.pool[index, 4] <- shapiro.test(coeflist.pool[[j]][ , i])$p.value
normal.pool[index, 5] <- ifelse(shapiro.test(coeflist.pool[[j]][ , i])$p.value > 0.1, "normal", "not normal")
normal.pool[index, 6] <- ifelse(shapiro.test(coeflist.pool[[j]][ , i])$p.value >= 0.05 &
shapiro.test(coeflist.pool[[j]][ , i])$p.value <= 0.1, "normal", "not normal")
# fe
normal.fe[index, 1] <- unitloop
normal.fe[index, 2] <- Nperloop
normal.fe[index, 3] <- truecor[i]
normal.fe[index, 4] <- shapiro.test(normal.fe[[j]][ , i])$p.value
normal.fe[index, 5] <- ifelse(shapiro.test(normal.fe[[j]][ , i])$p.value > 0.1, "normal", "not normal")
normal.fe[index, 6] <- ifelse(shapiro.test(normal.fe[[j]][ , i])$p.value >= 0.05 &
shapiro.test(normal.fe[[j]][ , i])$p.value <= 0.1, "normal", "not normal")
# re
normal.re[index, 1] <- unitloop
normal.re[index, 2] <- Nperloop
normal.re[index, 3] <- truecor[i]
normal.re[index, 4] <- shapiro.test(normal.re[[j]][ , i])$p.value
normal.re[index, 5] <- ifelse(shapiro.test(normal.re[[j]][ , i])$p.value > 0.1, "normal", "not normal")
normal.re[index, 6] <- ifelse(shapiro.test(normal.re[[j]][ , i])$p.value >= 0.05 &
shapiro.test(normal.re[[j]][ , i])$p.value <= 0.1, "normal", "not normal")
index <- index + 1
print(j)
}
j <- j + 1
}
}
normal.fe[index, 4] <- shapiro.test(normal.fe[[j]][ , i])$p.value
j
i
shapiro.test(normal.fe[[j]][ , i])$p.value
normal.fe[[j]][ , i]
normal.pool <- matrix(data = NA, nrow = 99, ncol = 6)
normal.fe <- matrix(data = NA, nrow = 99, ncol = 6)
normal.re <- matrix(data = NA, nrow = 99, ncol = 6)
index <- 1
j <- 1
for (unitloop in units) {
for (Nperloop in Nperunit) {
for (i in 1:length(truecor)) {
# pooled
normal.pool[index, 1] <- unitloop
normal.pool[index, 2] <- Nperloop
normal.pool[index, 3] <- truecor[i]
normal.pool[index, 4] <- shapiro.test(coeflist.pool[[j]][ , i])$p.value
normal.pool[index, 5] <- ifelse(shapiro.test(coeflist.pool[[j]][ , i])$p.value > 0.1, "normal", "not normal")
normal.pool[index, 6] <- ifelse(shapiro.test(coeflist.pool[[j]][ , i])$p.value >= 0.05 &
shapiro.test(coeflist.pool[[j]][ , i])$p.value <= 0.1, "normal", "not normal")
# fe
normal.fe[index, 1] <- unitloop
normal.fe[index, 2] <- Nperloop
normal.fe[index, 3] <- truecor[i]
normal.fe[index, 4] <- shapiro.test(coeflist.fe[[j]][ , i])$p.value
normal.fe[index, 5] <- ifelse(shapiro.test(coeflist.fe[[j]][ , i])$p.value > 0.1, "normal", "not normal")
normal.fe[index, 6] <- ifelse(shapiro.test(coeflist.fe[[j]][ , i])$p.value >= 0.05 &
shapiro.test(coeflist.fe[[j]][ , i])$p.value <= 0.1, "normal", "not normal")
# re
normal.re[index, 1] <- unitloop
normal.re[index, 2] <- Nperloop
normal.re[index, 3] <- truecor[i]
normal.re[index, 4] <- shapiro.test(coeflist.re[[j]][ , i])$p.value
normal.re[index, 5] <- ifelse(shapiro.test(coeflist.re[[j]][ , i])$p.value > 0.1, "normal", "not normal")
normal.re[index, 6] <- ifelse(shapiro.test(coeflist.re[[j]][ , i])$p.value >= 0.05 &
shapiro.test(coeflist.re[[j]][ , i])$p.value <= 0.1, "normal", "not normal")
index <- index + 1
print(j)
}
j <- j + 1
}
}
normal.pool
# normality
normal.pool <- matrix(data = NA, nrow = 99, ncol = 6)
normal.fe <- matrix(data = NA, nrow = 99, ncol = 6)
normal.re <- matrix(data = NA, nrow = 99, ncol = 6)
index <- 1
j <- 1
for (unitloop in units) {
for (Nperloop in Nperunit) {
for (i in 1:length(truecor)) {
# pooled
normal.pool[index, 1] <- unitloop
normal.pool[index, 2] <- Nperloop
normal.pool[index, 3] <- truecor[i]
normal.pool[index, 4] <- shapiro.test(coeflist.pool[[j]][ , i])$p.value
normal.pool[index, 5] <- ifelse(shapiro.test(coeflist.pool[[j]][ , i])$p.value > 0.1, "normal", "not normal")
normal.pool[index, 6] <- ifelse(shapiro.test(coeflist.pool[[j]][ , i])$p.value >= 0.05 &
shapiro.test(coeflist.pool[[j]][ , i])$p.value <= 0.1, "not normal", "normal")
# fe
normal.fe[index, 1] <- unitloop
normal.fe[index, 2] <- Nperloop
normal.fe[index, 3] <- truecor[i]
normal.fe[index, 4] <- shapiro.test(coeflist.fe[[j]][ , i])$p.value
normal.fe[index, 5] <- ifelse(shapiro.test(coeflist.fe[[j]][ , i])$p.value > 0.1, "normal", "not normal")
normal.fe[index, 6] <- ifelse(shapiro.test(coeflist.fe[[j]][ , i])$p.value >= 0.05 &
shapiro.test(coeflist.fe[[j]][ , i])$p.value <= 0.1, "not normal", "normal")
# re
normal.re[index, 1] <- unitloop
normal.re[index, 2] <- Nperloop
normal.re[index, 3] <- truecor[i]
normal.re[index, 4] <- shapiro.test(coeflist.re[[j]][ , i])$p.value
normal.re[index, 5] <- ifelse(shapiro.test(coeflist.re[[j]][ , i])$p.value > 0.1, "normal", "not normal")
normal.re[index, 6] <- ifelse(shapiro.test(coeflist.re[[j]][ , i])$p.value >= 0.05 &
shapiro.test(coeflist.re[[j]][ , i])$p.value <= 0.1, "not normal", "normal")
index <- index + 1
print(j)
}
j <- j + 1
}
}
normal.pool
normal.pool <- matrix(data = NA, nrow = 99, ncol = 6)
normal.fe <- matrix(data = NA, nrow = 99, ncol = 6)
normal.re <- matrix(data = NA, nrow = 99, ncol = 6)
index <- 1
j <- 1
for (unitloop in units) {
for (Nperloop in Nperunit) {
for (i in 1:length(truecor)) {
# pooled
normal.pool[index, 1] <- unitloop
normal.pool[index, 2] <- Nperloop
normal.pool[index, 3] <- truecor[i]
normal.pool[index, 4] <- shapiro.test(coeflist.pool[[j]][ , i])$p.value
normal.pool[index, 5] <- ifelse(shapiro.test(coeflist.pool[[j]][ , i])$p.value > 0.1, "normal", "not normal")
normal.pool[index, 6] <- ifelse(shapiro.test(coeflist.pool[[j]][ , i])$p.value > 0.05, "normal", "not normal")
# fe
normal.fe[index, 1] <- unitloop
normal.fe[index, 2] <- Nperloop
normal.fe[index, 3] <- truecor[i]
normal.fe[index, 4] <- shapiro.test(coeflist.fe[[j]][ , i])$p.value
normal.fe[index, 5] <- ifelse(shapiro.test(coeflist.fe[[j]][ , i])$p.value > 0.1, "normal", "not normal")
normal.fe[index, 6] <- ifelse(shapiro.test(coeflist.fe[[j]][ , i])$p.value > 0.05, "normal", "not normal")
# re
normal.re[index, 1] <- unitloop
normal.re[index, 2] <- Nperloop
normal.re[index, 3] <- truecor[i]
normal.re[index, 4] <- shapiro.test(coeflist.re[[j]][ , i])$p.value
normal.re[index, 5] <- ifelse(shapiro.test(coeflist.re[[j]][ , i])$p.value > 0.1, "normal", "not normal")
normal.re[index, 6] <- ifelse(shapiro.test(coeflist.re[[j]][ , i])$p.value > 0.05, "normal", "not normal")
index <- index + 1
print(j)
}
j <- j + 1
}
}
normal.fe
colnames(normal.pool) <- c("units", "within_units", "corr", "p_value", "normal_90", "normal_95")
normal.pool
